import Clipboard from 'clipboard';
import { showNotify } from 'vant/es';
function clipboardSuccess() {
  // ElMessage({
  //   message: '复制成功',
  //   type: 'success',
  //   duration: 1500,
  // });
  showNotify({
    type:'success',
    message: '复制成功',
    duration: 1500
  })
}

function clipboardError() {
  // ElMessage({
  //   message: '复制失败',
  //   type: 'error',
  // });
  showNotify({
    type:'danger',
    message: '复制失败',
    duration: 1500
  })
}

export default function handleClipboard(text: string, event: Event) {
  const clipboard = new Clipboard(event.target as HTMLElement, {
    text: () => text,
  });
  clipboard.on("success", () => {
    clipboardSuccess();
    clipboard.destroy();
  });
  clipboard.on("error", () => {
    clipboardError();
    clipboard.destroy();
  });
  (clipboard as any).onClick(event)
}

